// Copyright (c) 2024-present AI-Labs

import {
    AIChatConfig,
    AICommand,
    Text2ImageConfig
} from "@/ai/index.ts";
import { AppPlugin } from "@/plugins/AppPlugin.ts";
import { AppPluginRegistry } from "@/plugins/AppPluginRegistry.ts";

/**
 * 定义数据字典类型
 */
export type UAIEditorDict = {
    label: string,
    value: string | number,
    order?: number
}

/**
 * 定义文件上传类
 */
export type Uploader = (file: File, uploadUrl?: string, headers?: Record<string, any>, formName?: string) => Promise<Record<string, any>>;

/**
 * 定义编辑器选项配置类型
 */
export type UAIEditorOptions = {
    element: string | Element
    content?: string,
    dicts?: {
        fontFamilies?: UAIEditorDict[],
        fontSizes?: UAIEditorDict[],
        lineHeights?: UAIEditorDict[],
        symbols?: UAIEditorDict[],
        emojis?: UAIEditorDict[],
    },
    header?: "ribbon" | "classic",
    theme?: "light" | "dark",
    lang?: string,
    i18n?: Record<string, Record<string, string>>,
    image?: {
        uploadUrl?: string,
        uploadHeaders?: (() => Record<string, any>) | Record<string, any>,
        uploadFormName?: string,
        uploader?: Uploader,
    },
    video?: {
        uploadUrl?: string,
        uploadHeaders?: (() => Record<string, any>) | Record<string, any>,
        uploadFormName?: string,
        uploader?: Uploader,
    },
    audio?: {
        uploadUrl?: string,
        uploadHeaders?: (() => Record<string, any>) | Record<string, any>,
        uploadFormName?: string,
        uploader?: Uploader,
    },
    file?: {
        uploadUrl?: string,
        uploadHeaders?: (() => Record<string, any>) | Record<string, any>,
        uploadFormName?: string,
        uploader?: Uploader,
    },
    ai?: {
        chat?: {
            models?: Record<string, AIChatConfig>,
            commands?: AICommand[],
        },
        image?: {
            models?: {
                text2image?: Record<string, Text2ImageConfig>,
            },
            commands?: AICommand[]
        }
    },
    plugins?: AppPlugin[],
    pluginRegistry?: AppPluginRegistry
}
